var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  PracticeRoomDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.practiceArr = []),
        (t.max = 100),
        (t.min = 0),
        (t.step = 1),
        (t.num = 0),
        (t.selIndex = -1),
        (t.radio_Index = -1),
        t.btn_practice_back.on(Laya.Event.CLICK, t, t.onLibraryBackPre),
        t.btn_yanxi_sure.on(Laya.Event.CLICK, t, t.onYanXiSure),
        WebSocketService.addListener({
          caller: t,
          code: 1516,
          method: t.onXiuLianSelectAction,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1451,
          method: t.onLoadMySelfMoneyOnPracticeData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1520,
          method: t.onLoadSureYanXiOpteration,
        }),
        (t.list_gongfang_fujian.renderHandler = new Laya.Handler(
          t,
          t.UpdatePracticeRender
        )),
        (t.list_gongfang_fujian.vScrollBarSkin = ""),
        t.list_gongfang_fujian.on(Laya.Event.CLICK, t, t.onListDidClickAction),
        (t.radiogroup_xinfa.visible = !1),
        t.radio_practice_one.on(
          Laya.Event.CLICK,
          t,
          t.onRadioPracticeExpSelect
        ),
        t.radio_practice_two.on(
          Laya.Event.CLICK,
          t,
          t.onRadioPracticeExpSelect
        ),
        t.radio_practice_three.on(
          Laya.Event.CLICK,
          t,
          t.onRadioPracticeExpSelect
        ),
        t.radio_practice_four.on(
          Laya.Event.CLICK,
          t,
          t.onRadioPracticeExpSelect
        ),
        t.btn_yanxi_dele.on(Laya.Event.CLICK, t, t.onDidClickYanXiItemFn),
        t.btn_yanxi_plus.on(Laya.Event.CLICK, t, t.onDidClickYanXiItemFn),
        t.slider_yanxishu.on(Laya.Event.CHANGE, t, t.onSliderYanXiChange),
        (t.slider_yanxishu.min = 0),
        (t.slider_yanxishu.max = t.max),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openLibraryDialog = function (e) {
        return (
          null == this.pracRoomV && (this.pracRoomV = new t()),
          this.pracRoomV.popup(!0),
          (this.pracRoomV.radiogroup_xinfa.selectedIndex = -1),
          WebSocketService.send({ c: 1516 }),
          (this.pracRoomV.fangwu_lvl = e),
          (this.pracRoomV.num = 0),
          (this.pracRoomV.slider_yanxishu.value = this.pracRoomV.num),
          (this.pracRoomV.lable_yanxi_fee.text = "0金0分钟/0本"),
          this.pracRoomV.dealFangWuXinFaDisable(this.pracRoomV.fangwu_lvl),
          this.pracRoomV
        );
      }),
      (t.prototype.dealFangWuXinFaDisable = function (e) {
        (this.radio_practice_one.disabled = !1),
          (this.radio_practice_two.disabled = !1),
          (this.radio_practice_three.disabled = !1),
          (this.radio_practice_four.disabled = !1),
          e <= 3
            ? ((this.radio_practice_one.disabled = !0),
              (this.radio_practice_two.disabled = !0),
              (this.radio_practice_three.disabled = !0))
            : 4 == e &&
              ((this.radio_practice_one.disabled = !0),
              (this.radio_practice_two.disabled = !0));
      }),
      (t.prototype.onXiuLianSelectAction = function (e) {
        if (0 == e.code) {
          (this.practiceArr = []), (this.practiceArr = e.data);
          var t = void 0;
          if (((this.dataSource = []), this.practiceArr.length <= 0))
            (this.list_gongfang_fujian.visible = !1),
              (this.label_gongfang_emptyList.text = "暂无可用副将"),
              (this.label_gongfang_emptyList.visible = !0);
          else {
            (this.list_gongfang_fujian.visible = !0),
              (this.label_gongfang_emptyList.visible = !1),
              (this.label_gongfang_emptyList.text = "");
            for (var i = 0; i < this.practiceArr.length; i++) {
              var a = Utils.dealTransAndLvl(
                this.practiceArr[i].roleType,
                this.practiceArr[i].lvl
              );
              (t = {
                label_gongfang_name: {
                  text:
                    this.dealFujiangTouXian(this.practiceArr[i].s) +
                    " " +
                    this.practiceArr[i].name +
                    a,
                },
                fujiang_check: !1,
              }),
                this.dataSource.push(t);
            }
            this.list_gongfang_fujian.array = this.dataSource;
          }
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.dealFujiangTouXian = function (e) {
        return "1" == e
          ? "国士"
          : "2" == e
          ? "将才"
          : "3" == e
          ? "英才"
          : "常人";
      }),
      (t.prototype.UpdatePracticeRender = function (e, t) {
        if (!(t > this.practiceArr.length)) {
          var i = e.getChildByName("label_gongfang_name"),
            a = this.dataSource[t],
            n = e.getChildByName("fujiang_check");
          a.fujiang_check ? (n.selected = !0) : (n.selected = !1),
            "1" == this.practiceArr[t].s
              ? (i.color = "#800080")
              : "2" == this.practiceArr[t].s
              ? (i.color = "#1E90FF")
              : "3" == this.practiceArr[t].s
              ? (i.color = "#458B00")
              : (i.color = "#FFFFFF");
        }
      }),
      (t.prototype.onListDidClickAction = function (e) {
        if ("" != e.target.name) {
          if (-1 == e.target.name.indexOf("item")) {
            var t = this.practiceArr[this.list_gongfang_fujian.selectedIndex],
              i = this.list_gongfang_fujian.selectedIndex,
              a = Utils.transform(
                this.practiceArr[i].roleType % 10,
                "roleType"
              );
            if (
              ((this.fujiangObj = t),
              (this.lable_yanxi_fee.text = "0金0分钟/0本"),
              3 == t.s && this.radio_Index > 1)
            ) {
              if (
                (ToastView.toastView("英才无法使用"),
                e.target.selected && this.selIndex > -1)
              ) {
                var n = this.practiceArr[this.selIndex],
                  r = Utils.transform(
                    this.practiceArr[this.selIndex].roleType % 10,
                    "roleType"
                  );
                this.list_gongfang_fujian.setItem(this.selIndex, {
                  label_gongfang_name: {
                    text:
                      this.dealFujiangTouXian(
                        this.practiceArr[this.selIndex].s
                      ) +
                      " " +
                      n.name +
                      n.lvl +
                      "级 " +
                      r,
                  },
                  fujiang_check: !1,
                });
              }
            } else if (e.target.selected) {
              if (this.selIndex > -1) {
                var n = this.practiceArr[this.selIndex],
                  r = Utils.transform(
                    this.practiceArr[this.selIndex].roleType % 10,
                    "roleType"
                  );
                this.list_gongfang_fujian.setItem(this.selIndex, {
                  label_gongfang_name: {
                    text:
                      this.dealFujiangTouXian(
                        this.practiceArr[this.selIndex].s
                      ) +
                      " " +
                      n.name +
                      n.lvl +
                      "级 " +
                      r,
                  },
                  fujiang_check: !1,
                });
              }
              this.list_gongfang_fujian.setItem(i, {
                label_gongfang_name: {
                  text:
                    this.dealFujiangTouXian(this.practiceArr[i].s) +
                    " " +
                    t.name +
                    t.lvl +
                    "级 " +
                    a,
                },
                fujiang_check: !0,
              }),
                (this.selIndex = i);
            } else
              e.target &&
                this.list_gongfang_fujian.setItem(i, {
                  label_gongfang_name: {
                    text:
                      this.dealFujiangTouXian(this.practiceArr[i].s) +
                      " " +
                      t.name +
                      t.lvl +
                      "级 " +
                      a,
                  },
                  fujiang_check: !0,
                });
          }
        }
      }),
      (t.prototype.onRadioPracticeExpSelect = function (e) {
        if (
          ((this.radio_practice_one.selected = !1),
          (this.radio_practice_two.selected = !1),
          (this.radio_practice_three.selected = !1),
          (this.radio_practice_four.selected = !1),
          this.list_gongfang_fujian.selectedIndex > -1)
        ) {
          if (
            3 == this.practiceArr[this.list_gongfang_fujian.selectedIndex].s
          ) {
            if ("item3" != e.target.name) return;
            this.radio_practice_four.selected = !0;
          }
        }
        this.lable_yanxi_fee.text = "0金0分钟/0本";
        var t = 0;
        "item0" == e.target.name
          ? ((this.radio_practice_one.selected = !0),
            (this.label_yanxis_content.text = "密宗副将心法"),
            (t = 1))
          : "item1" == e.target.name
          ? ((this.radio_practice_two.selected = !0),
            (this.label_yanxis_content.text = "特级副将心法"),
            (t = 2))
          : "item2" == e.target.name
          ? ((this.radio_practice_three.selected = !0),
            (this.label_yanxis_content.text = "高级副将心法"),
            (t = 3))
          : "item3" == e.target.name &&
            ((this.radio_practice_four.selected = !0),
            (this.label_yanxis_content.text = "初级副将心法"),
            (t = 4)),
          (this.radio_Index = 5 - t);
        var i = this.preFeeMoneyNumber(t);
        (this.max = this.totalMoney / i), (this.slider_yanxishu.value = 0);
      }),
      (t.prototype.onLoadMySelfMoneyOnPracticeData = function (e) {
        this.totalMoney = e.data.gold;
      }),
      (t.prototype.onDidClickYanXiItemFn = function (e) {
        -1 != this.radio_Index &&
          ("item0" == e.target.name
            ? ((this.num = this.num - this.step),
              this.num < this.min && (this.num = this.min),
              (this.slider_yanxishu.value = this.num))
            : "item1" == e.target.name &&
              ((this.num = this.num + this.step),
              this.num > this.max && (this.num = this.max),
              (this.slider_yanxishu.value = this.num)),
          (this.lable_yanxi_fee.text = this.dealYanXiFeeWithMoney()));
      }),
      (t.prototype.onSliderYanXiChange = function () {
        (this.num = this.slider_yanxishu.value),
          (this.lable_yanxi_fee.text = this.dealYanXiFeeWithMoney());
      }),
      (t.prototype.dealYanXiFeeWithMoney = function () {
        var e = this.fangwu_lvl,
          t = "",
          i = this.radio_Index;
        return (
          1 == e ||
            2 == e ||
            (3 == e
              ? ((t = this.preFeeMoneyNumber(i) * this.num + "金"),
                this.preFeeTimerNumber() * this.num + "分钟")
              : 4 == e
              ? ((t = this.preFeeMoneyNumber(i) * this.num + "金"),
                this.preFeeTimerNumber() * this.num + "分钟")
              : 5 == e &&
                ((t = this.preFeeMoneyNumber(i) * this.num + "金"),
                this.preFeeTimerNumber() * this.num + "分钟")),
          t +
            this.ChangeHourMinutestr(this.preFeeTimerNumber() * this.num) +
            "/" +
            this.num +
            "本"
        );
      }),
      (t.prototype.ChangeHourMinutestr = function (e) {
        var t = Math.floor(e / 60),
          i = Math.floor(e % 60);
        return t < 1 ? i + "分钟" : t + "小时" + i + "分钟";
      }),
      (t.prototype.preFeeMoneyNumber = function (e) {
        var t = 0;
        return (
          3 == this.fangwu_lvl
            ? 1 == e && (t = 30)
            : 4 == this.fangwu_lvl
            ? 1 == e
              ? (t = 30)
              : 2 == e && (t = 40)
            : 5 == this.fangwu_lvl &&
              (1 == e
                ? (t = 30)
                : 2 == e
                ? (t = 40)
                : 3 == e
                ? (t = 50)
                : 4 == e && (t = 60)),
          t
        );
      }),
      (t.prototype.preFeeTimerNumber = function () {
        var e = 0;
        return (
          3 == this.fangwu_lvl
            ? (e = 60)
            : 4 == this.fangwu_lvl
            ? (e = 40)
            : 5 == this.fangwu_lvl && (e = 20),
          e
        );
      }),
      (t.prototype.onYanXiSure = function () {
        if (this.fujiangObj) {
          var e = this.fujiangObj.id,
            t = this.radio_Index,
            i = this.num;
          e && t && i
            ? WebSocketService.send({ c: 1520, d: { id: e, l: t, c: i } })
            : ToastView.toastView("请选择完整");
        }
      }),
      (t.prototype.onLoadSureYanXiOpteration = function (e) {
        0 == e.code && ToastView.toastView(e.data);
      }),
      (t.prototype.onLibraryBackPre = function () {
        t.close();
      }),
      (t.close = function () {
        this.pracRoomV && (this.pracRoomV.close(), (this.pracRoomV = null));
      }),
      t
    );
  })(ui.Estatemarket.PracticeRoomDialogUI);
